import { FC } from "react";
import { Route, Routes } from "react-router-dom";
import routes, { RouterProps } from "./router/routes";

const App: FC = () => {
  function RouteAuthFun(routeList: RouterProps[]) {
    return routeList.map(
      item => {
        return <Route
          path={item.path}
          element={<item.element />} 
          key={item.path}
        >
          {item?.children && RouteAuthFun(item.children)}
        </Route>
      }
    );
  }
  return <Routes>{RouteAuthFun(routes)}</Routes>;
};

export default App;
